<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no" >

  <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.4.1/jquery.min.js" integrity="sha256-CSXorXvZcTkaix6Yvo6HppcZGetbYMGWSFlBw8HfCJo=" crossorigin="anonymous"></script>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/turbolinks/5.2.0/turbolinks.js" integrity="sha256-iM4Yzi/zLj/IshPWMC1IluRxTtRjMqjPGd97TZ9yYpU=" crossorigin="anonymous"></script>
  <link href="https://fonts.googleapis.com/css?family=Roboto+Mono" rel="stylesheet">
  <link href="https://fonts.googleapis.com/css?family=Cousine|Inconsolata" rel="stylesheet">
  <link rel="shortcut icon" type="image/png" href="/favicon.png">

  <link rel="stylesheet" href="/css/style.css">
  <link rel="stylesheet" href="/css/css/fontawesome-all.min.css">
  <link rel="stylesheet" href="/css/css/work-sans-v7.css">
  <script src="/js/main.js"></script>

  <!-- Begin Jekyll SEO tag v2.6.1 -->
<title>JS: Get Account Replies | Hive Developer</title>
<meta name="generator" content="Jekyll v4.0.0" />
<meta property="og:title" content="JS: Get Account Replies" />
<meta property="og:locale" content="en_US" />
<meta name="description" content="How to get replies made on particular account’s content." />
<meta property="og:description" content="How to get replies made on particular account’s content." />
<link rel="canonical" href="get_account_replies.html" />
<meta property="og:url" content="get_account_replies.html" />
<meta property="og:site_name" content="Hive Developer" />
<meta property="og:type" content="article" />
<meta property="article:published_time" content="2020-08-26T11:52:22-07:00" />
<script type="application/ld+json">
{"description":"How to get replies made on particular account’s content.","mainEntityOfPage":{"@type":"WebPage","@id":"get_account_replies.html"},"@type":"BlogPosting","url":"get_account_replies.html","headline":"JS: Get Account Replies","dateModified":"2020-08-26T11:52:22-07:00","datePublished":"2020-08-26T11:52:22-07:00","@context":"https://schema.org"}</script>
<!-- End Jekyll SEO tag -->


  
</head>
<body>
<header>
  <h1>
    <button type="button" class="open-nav" id="open-nav"></button>
    <a href="/"  class="logo-link"><img src="/images/logotype_black.svg" height="40" alt="Hive Developer logo"></a>
  </h1>

  
  <form action="/search/" method="get">
    <input type="text" name="q" id="search-input" placeholder="Search">
    <input type="submit" value="Search" style="display: none;">
  </form>
  

  <div id="sidebar" class="sidebar">
	
	
	
		
    <section class="pnl-main-nav-section main-nav-section" url="/">
		<h6 class="ctrl-nav-section title">Introduction</h6>
		<ul class="cont-nav-section content">
			
				
					
					
						
						<li><a href="/#introduction-welcome">Welcome to Hive</a></li>
						
					
				
			
		</ul>
	</section>
	
		
    <section class="pnl-main-nav-section main-nav-section" url="/quickstart/">
		<h6 class="ctrl-nav-section title">Quickstart</h6>
		<ul class="cont-nav-section content">
			
				
					
					
						
						<li><a href="/quickstart/#quickstart-choose-library">Choose Library</a></li>
						
					
						
						<li><a href="/quickstart/#quickstart-hive-full-nodes">Hive Nodes</a></li>
						
					
						
						<li><a href="/quickstart/#quickstart-testnet">Hive Testnet</a></li>
						
					
				
			
		</ul>
	</section>
	
		
    <section class="pnl-main-nav-section main-nav-section" url="/tutorials/">
		<h6 class="ctrl-nav-section title">Tutorials</h6>
		<ul class="cont-nav-section content">
			
				
					
						<li><a href="/tutorials/#tutorials-javascript">Javascript</a></li>
					
				
					
						<li><a href="/tutorials/#tutorials-python">Python</a></li>
					
				
					
						<li><a href="/tutorials/#tutorials-ruby">Ruby</a></li>
					
				
					
						<li><a href="/tutorials/#tutorials-recipes">Recipes</a></li>
					
				
			
		</ul>
	</section>
	
		
    <section class="pnl-main-nav-section main-nav-section" url="/services/">
		<h6 class="ctrl-nav-section title">Services</h6>
		<ul class="cont-nav-section content">
			
				
					
					
						
						<li><a href="/services/#services-hive-blog">hive.blog</a></li>
						
					
						
						<li><a href="/services/#services-hivesigner">HiveSigner</a></li>
						
					
						
						<li><a href="/services/#services-jussi">Jussi</a></li>
						
					
						
						<li><a href="/services/#services-imagehoster">ImageHoster</a></li>
						
					
						
						<li><a href="/services/#services-dhf">DHF</a></li>
						
					
				
			
		</ul>
	</section>
	
		
    <section class="pnl-main-nav-section main-nav-section" url="/apidefinitions/">
		<h6 class="ctrl-nav-section title">Appbase API</h6>
		<ul class="cont-nav-section content">
			
				
					
					
						
						<li><a href="/apidefinitions/#apidefinitions-condenser-api">Condenser Api</a></li>
						
					
						
						<li><a href="/apidefinitions/#apidefinitions-bridge">Bridge</a></li>
						
					
						
						<li><a href="/apidefinitions/#apidefinitions-account-by-key-api">Account By Key Api</a></li>
						
					
						
						<li><a href="/apidefinitions/#apidefinitions-account-history-api">Account History Api</a></li>
						
					
						
						<li><a href="/apidefinitions/#apidefinitions-block-api">Block Api</a></li>
						
					
						
						<li><a href="/apidefinitions/#apidefinitions-database-api">Database Api</a></li>
						
					
						
						<li><a href="/apidefinitions/#apidefinitions-debug-node-api">Debug Node Api</a></li>
						
					
						
						<li><a href="/apidefinitions/#apidefinitions-follow-api">Follow Api</a></li>
						
					
						
						<li><a href="/apidefinitions/#apidefinitions-jsonrpc">Jsonrpc</a></li>
						
					
						
						<li><a href="/apidefinitions/#apidefinitions-market-history-api">Market History Api</a></li>
						
					
						
						<li><a href="/apidefinitions/#apidefinitions-network-broadcast-api">Network Broadcast Api</a></li>
						
					
						
						<li><a href="/apidefinitions/#apidefinitions-rc-api">Rc Api</a></li>
						
					
						
						<li><a href="/apidefinitions/#apidefinitions-reputation-api">Reputation Api</a></li>
						
					
						
						<li><a href="/apidefinitions/#apidefinitions-rewards-api">Rewards Api</a></li>
						
					
						
						<li><a href="/apidefinitions/#apidefinitions-tags-api">Tags Api</a></li>
						
					
						
						<li><a href="/apidefinitions/#apidefinitions-transaction-status-api">Transaction Status Api</a></li>
						
					
						
						<li><a href="/apidefinitions/#apidefinitions-witness-api">Witness Api</a></li>
						
					
						
						<li><a href="/apidefinitions/#apidefinitions-broadcast-ops">Broadcast Ops</a></li>
						
					
						
						<li><a href="/apidefinitions/#apidefinitions-broadcast-ops-communities">Broadcast Ops Communities</a></li>
						
					
				
			
		</ul>
	</section>
	
		
    <section class="pnl-main-nav-section main-nav-section" url="/resources/">
		<h6 class="ctrl-nav-section title">Resources</h6>
		<ul class="cont-nav-section content">
			
				
					
					
						
						<li><a href="/resources/#resources-overview">Overview</a></li>
						
					
						
						<li><a href="/resources/#resources-client-libs">Client Libraries</a></li>
						
					
						
						<li><a href="/resources/#resources-bluepaper">Bluepaper</a></li>
						
					
						
						<li><a href="/resources/#resources-whitepaper">Whitepaper</a></li>
						
					
						
						<li><a href="/resources/#resources-tools">Tools</a></li>
						
					
						
						<li><a href="/resources/#resources-hivesigner-libs">Hivesigner Libs</a></li>
						
					
						
						<li><a href="/resources/#resources-hive-keychain">Hive Keychain</a></li>
						
					
						
						<li><a href="/resources/#resources-developeradvocate">Community & Help</a></li>
						
					
				
			
		</ul>
	</section>
	
		
    <section class="pnl-main-nav-section main-nav-section" url="/glossary/">
		<h6 class="ctrl-nav-section title">Glossary</h6>
		<ul class="cont-nav-section content">
			
				
					
					
						
						<li><a href="/glossary/#glossary-chain-basics">Chain Basics</a></li>
						
					
						
					
						
						<li><a href="/glossary/#glossary-governance">Governance</a></li>
						
					
						
						<li><a href="/glossary/#glossary-transactions">Transactions</a></li>
						
					
						
						<li><a href="/glossary/#glossary-api">API</a></li>
						
					
						
						<li><a href="/glossary/#glossary-market">Market</a></li>
						
					
				
			
		</ul>
	</section>
	
</div>



  <link href="https://fonts.googleapis.com/css?family=Nunito" rel="stylesheet">
</header>
<div class="main" id="top">
  <div class="hero">
    <h1 class="hero__h1">Hive Developer Portal </h1>
    <img class="hero__img" src="/images/honey-comb-92.png" style="position: relative; top: 10px;" />
  </div>
  <section id="tutorials-javascript-get-account-replies" class="row tutorials-javascript-get-account-replies">
	<h3>
		<a id="tutorials-javascript-get-account-replies">
			JS: Get Account Replies
			
		</a>
	</h3>
	
		<span class="description"><p>How to get replies made on particular account’s content.</p>
</span>
	

	<p>Full, runnable src of <a href="https://gitlab.syncad.com/hive/devportal/-/tree/master/tutorials/javascript/08_get_account_replies">Get Account Replies</a> can be downloaded as part of: <a href="https://gitlab.syncad.com/hive/devportal/-/tree/master/tutorials/javascript">tutorials/javascript</a> (or download just this tutorial: <a href="https://gitlab.syncad.com/hive/devportal/-/archive/master/devportal-master.zip?path=tutorials/javascript/08_get_account_replies">devportal-master-tutorials-javascript-08_get_account_replies.zip</a>).</p>

<p>The purpose of this tutorial is <strong>How to get account replies</strong> and <strong>a)</strong> demonstrate how to use <code class="highlighter-rouge">get_state</code> api function call, and <strong>b)</strong> fetch recent replies for the content of specific account, in this case <code class="highlighter-rouge">@hiveio</code>.</p>

<p>We focus on listing part of the content with simply UI as well as explain the most commonly used fields from the response object as well as parse body of each comment.</p>

<h2 id="intro">Intro</h2>

<p>We are using <code class="highlighter-rouge">get_state</code> function with <code class="highlighter-rouge">dhive</code>, which is straight-forward and this function returns current state of the network as well as additional content given proper query. Each content body, as we described in previous tutorials, is written markdown and submitted to the blockchain by many applications built on top of Hive. For that reason we are using <code class="highlighter-rouge">remarkable</code> npm package to parse markdown in a readable format.</p>

<h2 id="steps">Steps</h2>

<ol>
  <li><a href="#app-setup"><strong>App setup</strong></a> Setup app packages</li>
  <li><a href="#query-result"><strong>Query result</strong></a> Form a proper query and retrieve result</li>
  <li><a href="#display-replies"><strong>Display replies</strong></a> Parse and display result in user interface</li>
</ol>

<h4 id="1-app-setup">1. App setup<a name="app-setup"></a></h4>

<p>As usual, we have <code class="highlighter-rouge">public/app.js</code> file which holds the javascript part of the tutorial. In first few lines we define, configure library and packages.</p>

<div class="language-javascript highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="kd">const</span> <span class="nx">dhive</span> <span class="o">=</span> <span class="nx">require</span><span class="p">(</span><span class="dl">'</span><span class="s1">@hivechain/dhive</span><span class="dl">'</span><span class="p">);</span>
<span class="kd">let</span> <span class="nx">opts</span> <span class="o">=</span> <span class="p">{};</span>
<span class="c1">//connect to production server</span>
<span class="nx">opts</span><span class="p">.</span><span class="nx">addressPrefix</span> <span class="o">=</span> <span class="dl">'</span><span class="s1">STM</span><span class="dl">'</span><span class="p">;</span>
<span class="nx">opts</span><span class="p">.</span><span class="nx">chainId</span> <span class="o">=</span>
    <span class="dl">'</span><span class="s1">0000000000000000000000000000000000000000000000000000000000000000</span><span class="dl">'</span><span class="p">;</span>
<span class="c1">//connect to server which is connected to the network/production</span>
<span class="kd">const</span> <span class="nx">client</span> <span class="o">=</span> <span class="k">new</span> <span class="nx">dhive</span><span class="p">.</span><span class="nx">Client</span><span class="p">(</span><span class="dl">'</span><span class="s1">https://api.openhive.network</span><span class="dl">'</span><span class="p">);</span>

<span class="kd">const</span> <span class="nx">Remarkable</span> <span class="o">=</span> <span class="nx">require</span><span class="p">(</span><span class="dl">'</span><span class="s1">remarkable</span><span class="dl">'</span><span class="p">);</span>
<span class="kd">const</span> <span class="nx">md</span> <span class="o">=</span> <span class="k">new</span> <span class="nx">Remarkable</span><span class="p">({</span> <span class="na">html</span><span class="p">:</span> <span class="kc">true</span><span class="p">,</span> <span class="na">linkify</span><span class="p">:</span> <span class="kc">true</span> <span class="p">});</span>
</code></pre></div></div>

<p><code class="highlighter-rouge">dhive</code> is pointing to the main network and proper chain_id, addressPrefix and connection server.
<code class="highlighter-rouge">remarkable</code> is assigned to <code class="highlighter-rouge">md</code> variable with linkify and html options, allowing markdown parsing links and html properly.</p>

<h4 id="2-query-result">2. Query result<a name="query-result"></a></h4>

<p>Next, we have <code class="highlighter-rouge">main</code> function which fires when page is loaded.</p>

<div class="language-javascript highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="c1">// query string, fetching recent replies for @hiveio account</span>
<span class="kd">const</span> <span class="nx">query</span> <span class="o">=</span> <span class="dl">'</span><span class="s1">/@hiveio/recent-replies</span><span class="dl">'</span><span class="p">;</span>

<span class="nx">client</span><span class="p">.</span><span class="nx">database</span><span class="p">.</span><span class="nx">call</span><span class="p">(</span><span class="dl">'</span><span class="s1">get_state</span><span class="dl">'</span><span class="p">,</span> <span class="p">[</span><span class="nx">query</span><span class="p">]).</span><span class="nx">then</span><span class="p">(</span><span class="nx">result</span> <span class="o">=&gt;</span> <span class="p">{</span>
    <span class="c1">// work with state object</span>
<span class="p">});</span>
</code></pre></div></div>

<p>Query is the path which we want to extract from Hive blockchain state. In our example we are using <code class="highlighter-rouge">@hiveio</code> account and <code class="highlighter-rouge">recent-replies</code> to its content. Result will be current state object with various information as well as <code class="highlighter-rouge">content</code> object property holding content of the query.</p>

<p>Following is example of returned object:</p>

<div class="language-json highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="p">{</span><span class="w">
    </span><span class="nl">"current_route"</span><span class="p">:</span><span class="s2">"/@hiveio/recent-replies"</span><span class="p">,</span><span class="w">
    </span><span class="nl">"props"</span><span class="p">:{</span><span class="w">
        </span><span class="nl">"head_block_number"</span><span class="p">:</span><span class="mi">22307429</span><span class="p">,</span><span class="w">
        </span><span class="nl">"head_block_id"</span><span class="p">:</span><span class="s2">"01546265c9dc3e761add4c4b652743e3c640fa19"</span><span class="p">,</span><span class="w">
        </span><span class="nl">"time"</span><span class="p">:</span><span class="s2">"2018-05-10T12:15:30"</span><span class="p">,</span><span class="w">
        </span><span class="nl">"current_witness"</span><span class="p">:</span><span class="s2">"smooth.witness"</span><span class="p">,</span><span class="w">
        </span><span class="nl">"total_pow"</span><span class="p">:</span><span class="mi">514415</span><span class="p">,</span><span class="w">
        </span><span class="nl">"num_pow_witnesses"</span><span class="p">:</span><span class="mi">172</span><span class="p">,</span><span class="w">
        </span><span class="nl">"virtual_supply"</span><span class="p">:</span><span class="s2">"271970374.699 HIVE"</span><span class="p">,</span><span class="w">
        </span><span class="nl">"current_supply"</span><span class="p">:</span><span class="s2">"268140818.508 HIVE"</span><span class="p">,</span><span class="w">
        </span><span class="nl">"confidential_supply"</span><span class="p">:</span><span class="s2">"0.000 HIVE"</span><span class="p">,</span><span class="w">
        </span><span class="nl">"current_sbd_supply"</span><span class="p">:</span><span class="s2">"13342173.771 HBD"</span><span class="p">,</span><span class="w">
        </span><span class="nl">"confidential_sbd_supply"</span><span class="p">:</span><span class="s2">"0.000 HBD"</span><span class="p">,</span><span class="w">
        </span><span class="nl">"total_vesting_fund_steem"</span><span class="p">:</span><span class="s2">"191002132.498 HIVE"</span><span class="p">,</span><span class="w">
        </span><span class="nl">"total_vesting_shares"</span><span class="p">:</span><span class="s2">"388786707656.308148 VESTS"</span><span class="p">,</span><span class="w">
        </span><span class="nl">"total_reward_fund_steem"</span><span class="p">:</span><span class="s2">"0.000 HIVE"</span><span class="p">,</span><span class="w">
        </span><span class="nl">"total_reward_shares2"</span><span class="p">:</span><span class="s2">"0"</span><span class="p">,</span><span class="w">
        </span><span class="nl">"pending_rewarded_vesting_shares"</span><span class="p">:</span><span class="s2">"366359809.533218 VESTS"</span><span class="p">,</span><span class="w">
        </span><span class="nl">"pending_rewarded_vesting_steem"</span><span class="p">:</span><span class="s2">"178575.754 HIVE"</span><span class="p">,</span><span class="w">
        </span><span class="nl">"sbd_interest_rate"</span><span class="p">:</span><span class="mi">0</span><span class="p">,</span><span class="w">
        </span><span class="nl">"sbd_print_rate"</span><span class="p">:</span><span class="mi">10000</span><span class="p">,</span><span class="w">
        </span><span class="nl">"maximum_block_size"</span><span class="p">:</span><span class="mi">65536</span><span class="p">,</span><span class="w">
        </span><span class="nl">"current_aslot"</span><span class="p">:</span><span class="mi">22373110</span><span class="p">,</span><span class="w">
        </span><span class="nl">"recent_slots_filled"</span><span class="p">:</span><span class="s2">"340282366920938463463374607431768211455"</span><span class="p">,</span><span class="w">
        </span><span class="nl">"participation_count"</span><span class="p">:</span><span class="mi">128</span><span class="p">,</span><span class="w">
        </span><span class="nl">"last_irreversible_block_num"</span><span class="p">:</span><span class="mi">22307411</span><span class="p">,</span><span class="w">
        </span><span class="nl">"vote_power_reserve_rate"</span><span class="p">:</span><span class="mi">10</span><span class="p">,</span><span class="w">
        </span><span class="nl">"average_block_size"</span><span class="p">:</span><span class="mi">14881</span><span class="p">,</span><span class="w">
        </span><span class="nl">"current_reserve_ratio"</span><span class="p">:</span><span class="mi">200000000</span><span class="p">,</span><span class="w">
        </span><span class="nl">"max_virtual_bandwidth"</span><span class="p">:</span><span class="s2">"264241152000000000000"</span><span class="w">
    </span><span class="p">},</span><span class="w">
    </span><span class="nl">"tag_idx"</span><span class="p">:{</span><span class="w">
        </span><span class="nl">"trending"</span><span class="p">:[</span><span class="s2">""</span><span class="p">,</span><span class="s2">"life"</span><span class="p">,</span><span class="s2">"photography"</span><span class="p">,</span><span class="s2">"hiveio"</span><span class="p">,</span><span class="s2">"kr"</span><span class="p">,</span><span class="s2">"introduceyourself"</span><span class="p">,</span><span class="s2">"bitcoin"</span><span class="p">,</span><span class="s2">"art"</span><span class="p">,</span><span class="s2">"travel"</span><span class="p">,</span><span class="s2">"cryptocurrency"</span><span class="p">,</span><span class="s2">"spanish"</span><span class="p">,</span><span class="s2">"food"</span><span class="p">,</span><span class="s2">"hive"</span><span class="p">,</span><span class="s2">"blog"</span><span class="p">,</span><span class="s2">"funny"</span><span class="p">,</span><span class="s2">"news"</span><span class="p">,</span><span class="s2">"nature"</span><span class="p">,</span><span class="s2">"colorchallenge"</span><span class="p">,</span><span class="s2">"dtube"</span><span class="p">,</span><span class="s2">"indonesia"</span><span class="p">,</span><span class="s2">"story"</span><span class="p">,</span><span class="s2">"cn"</span><span class="p">,</span><span class="s2">"money"</span><span class="p">,</span><span class="s2">"music"</span><span class="p">,</span><span class="s2">"writing"</span><span class="p">,</span><span class="s2">"crypto"</span><span class="p">,</span><span class="s2">"contest"</span><span class="p">,</span><span class="s2">"busy"</span><span class="p">,</span><span class="s2">"health"</span><span class="p">,</span><span class="s2">"poetry"</span><span class="p">,</span><span class="s2">"meme"</span><span class="p">,</span><span class="s2">"video"</span><span class="p">,</span><span class="s2">"utopian-io"</span><span class="p">,</span><span class="s2">"photo"</span><span class="p">,</span><span class="s2">"new"</span><span class="p">,</span><span class="s2">"love"</span><span class="p">,</span><span class="s2">"blockchain"</span><span class="p">,</span><span class="s2">"deutsch"</span><span class="p">,</span><span class="s2">"dmania"</span><span class="p">,</span><span class="s2">"science"</span><span class="p">,</span><span class="s2">"technology"</span><span class="p">,</span><span class="s2">"aceh"</span><span class="p">,</span><span class="s2">"entertainment"</span><span class="p">,</span><span class="s2">"gaming"</span><span class="p">,</span><span class="s2">"politics"</span><span class="p">,</span><span class="s2">"myanmar"</span><span class="p">,</span><span class="s2">"esteem"</span><span class="p">,</span><span class="s2">"sports"</span><span class="p">,</span><span class="s2">"fun"</span><span class="p">,</span><span class="s2">"tr"</span><span class="p">]</span><span class="w">
    </span><span class="p">},</span><span class="w">
    </span><span class="nl">"tags"</span><span class="p">:{},</span><span class="w">
    </span><span class="nl">"content"</span><span class="p">:{</span><span class="w">
        </span><span class="nl">"afm007/afm007-re-hiveio-devportal-update-3-ux-improvements-more-javascript-tutorials-and-more-20180509t050215510z"</span><span class="p">:{</span><span class="w">
            </span><span class="nl">"id"</span><span class="p">:</span><span class="mi">47669989</span><span class="p">,</span><span class="w">
            </span><span class="nl">"author"</span><span class="p">:</span><span class="s2">"afm007"</span><span class="p">,</span><span class="w">
            </span><span class="nl">"permlink"</span><span class="p">:</span><span class="s2">"afm007-re-hiveio-devportal-update-3-ux-improvements-more-javascript-tutorials-and-more-20180509t050215510z"</span><span class="p">,</span><span class="w">
            </span><span class="nl">"category"</span><span class="p">:</span><span class="s2">"hive"</span><span class="p">,</span><span class="w">
            </span><span class="nl">"parent_author"</span><span class="p">:</span><span class="s2">"hiveio"</span><span class="p">,</span><span class="w">
            </span><span class="nl">"parent_permlink"</span><span class="p">:</span><span class="s2">"devportal-update-3-ux-improvements-more-javascript-tutorials-and-more"</span><span class="p">,</span><span class="nl">"title"</span><span class="p">:</span><span class="s2">""</span><span class="p">,</span><span class="nl">"body"</span><span class="p">:</span><span class="s2">"I want to learn the Python language."</span><span class="p">,</span><span class="w">
            </span><span class="nl">"json_metadata"</span><span class="p">:</span><span class="s2">"{''}"</span><span class="p">,</span><span class="w">
            </span><span class="nl">"last_update"</span><span class="p">:</span><span class="s2">"2018-05-09T05:02:15"</span><span class="p">,</span><span class="w">
            </span><span class="nl">"created"</span><span class="p">:</span><span class="s2">"2018-05-09T05:02:15"</span><span class="p">,</span><span class="w">
            </span><span class="nl">"active"</span><span class="p">:</span><span class="s2">"2018-05-09T05:02:15"</span><span class="p">,</span><span class="w">
            </span><span class="nl">"last_payout"</span><span class="p">:</span><span class="s2">"1970-01-01T00:00:00"</span><span class="p">,</span><span class="w">
            </span><span class="nl">"depth"</span><span class="p">:</span><span class="mi">1</span><span class="p">,</span><span class="w">
            </span><span class="nl">"children"</span><span class="p">:</span><span class="mi">0</span><span class="p">,</span><span class="w">
            </span><span class="nl">"net_rshares"</span><span class="p">:</span><span class="mi">1057692008</span><span class="p">,</span><span class="w">
            </span><span class="nl">"abs_rshares"</span><span class="p">:</span><span class="mi">1057692008</span><span class="p">,</span><span class="w">
            </span><span class="nl">"vote_rshares"</span><span class="p">:</span><span class="mi">1057692008</span><span class="p">,</span><span class="w">
            </span><span class="nl">"children_abs_rshares"</span><span class="p">:</span><span class="mi">0</span><span class="p">,</span><span class="w">
            </span><span class="nl">"cashout_time"</span><span class="p">:</span><span class="s2">"2018-05-16T05:02:15"</span><span class="p">,</span><span class="w">
            </span><span class="nl">"max_cashout_time"</span><span class="p">:</span><span class="s2">"1969-12-31T23:59:59"</span><span class="p">,</span><span class="w">
            </span><span class="nl">"total_vote_weight"</span><span class="p">:</span><span class="mi">32523</span><span class="p">,</span><span class="w">
            </span><span class="nl">"reward_weight"</span><span class="p">:</span><span class="mi">10000</span><span class="p">,</span><span class="w">
            </span><span class="nl">"total_payout_value"</span><span class="p">:</span><span class="s2">"0.000 HBD"</span><span class="p">,</span><span class="w">
            </span><span class="nl">"curator_payout_value"</span><span class="p">:</span><span class="s2">"0.000 HBD"</span><span class="p">,</span><span class="w">
            </span><span class="nl">"author_rewards"</span><span class="p">:</span><span class="mi">0</span><span class="p">,</span><span class="w">
            </span><span class="nl">"net_votes"</span><span class="p">:</span><span class="mi">1</span><span class="p">,</span><span class="w">
            </span><span class="nl">"root_author"</span><span class="p">:</span><span class="s2">"hiveio"</span><span class="p">,</span><span class="w">
            </span><span class="nl">"root_permlink"</span><span class="p">:</span><span class="s2">"devportal-update-3-ux-improvements-more-javascript-tutorials-and-more"</span><span class="p">,</span><span class="w">
            </span><span class="nl">"max_accepted_payout"</span><span class="p">:</span><span class="s2">"1000000.000 HBD"</span><span class="p">,</span><span class="w">
            </span><span class="nl">"percent_steem_dollars"</span><span class="p">:</span><span class="mi">10000</span><span class="p">,</span><span class="w">
            </span><span class="nl">"allow_replies"</span><span class="p">:</span><span class="kc">true</span><span class="p">,</span><span class="w">
            </span><span class="nl">"allow_votes"</span><span class="p">:</span><span class="kc">true</span><span class="p">,</span><span class="w">
            </span><span class="nl">"allow_curation_rewards"</span><span class="p">:</span><span class="kc">true</span><span class="p">,</span><span class="w">
            </span><span class="nl">"beneficiaries"</span><span class="p">:[],</span><span class="w">
            </span><span class="nl">"url"</span><span class="p">:</span><span class="s2">"/hive/@hiveio/devportal-update-3-ux-improvements-more-javascript-tutorials-and-more#@afm007/afm007-re-hiveio-devportal-update-3-ux-improvements-more-javascript-tutorials-and-more-20180509t050215510z"</span><span class="p">,</span><span class="w">
            </span><span class="nl">"root_title"</span><span class="p">:</span><span class="s2">"DevPortal Update #3: UX Improvements, More Javascript Tutorials and More!"</span><span class="p">,</span><span class="w">
            </span><span class="nl">"pending_payout_value"</span><span class="p">:</span><span class="s2">"0.005 HBD"</span><span class="p">,</span><span class="w">
            </span><span class="nl">"total_pending_payout_value"</span><span class="p">:</span><span class="s2">"0.000 HIVE"</span><span class="p">,</span><span class="w">
            </span><span class="nl">"active_votes"</span><span class="p">:[{</span><span class="nl">"voter"</span><span class="p">:</span><span class="s2">"afm007"</span><span class="p">,</span><span class="nl">"weight"</span><span class="p">:</span><span class="mi">17182</span><span class="p">,</span><span class="nl">"rshares"</span><span class="p">:</span><span class="mi">1057692008</span><span class="p">,</span><span class="nl">"percent"</span><span class="p">:</span><span class="mi">10000</span><span class="p">,</span><span class="nl">"reputation"</span><span class="p">:</span><span class="s2">"855556264424"</span><span class="p">,</span><span class="nl">"time"</span><span class="p">:</span><span class="s2">"2018-05-09T05:18:06"</span><span class="p">}],</span><span class="w">
            </span><span class="nl">"replies"</span><span class="p">:[],</span><span class="w">
            </span><span class="nl">"author_reputation"</span><span class="p">:</span><span class="s2">"855556264424"</span><span class="p">,</span><span class="w">
            </span><span class="nl">"promoted"</span><span class="p">:</span><span class="s2">"0.000 HBD"</span><span class="p">,</span><span class="w">
            </span><span class="nl">"body_length"</span><span class="p">:</span><span class="mi">0</span><span class="p">,</span><span class="w">
            </span><span class="nl">"reblogged_by"</span><span class="p">:[]</span><span class="w">
        </span><span class="p">},</span><span class="w">
        </span><span class="nl">"andreina89/re-hiveio-devportal-update-3-ux-improvements-more-javascript-tutorials-and-more-20180509t045305223z"</span><span class="p">:{</span><span class="w">
            </span><span class="nl">"id"</span><span class="p">:</span><span class="mi">47669080</span><span class="p">,</span><span class="w">
            </span><span class="nl">"author"</span><span class="p">:</span><span class="s2">"andreina89"</span><span class="p">,</span><span class="w">
            </span><span class="nl">"permlink"</span><span class="p">:</span><span class="s2">"re-hiveio-devportal-update-3-ux-improvements-more-javascript-tutorials-and-more-20180509t045305223z"</span><span class="p">,</span><span class="w">
            </span><span class="nl">"category"</span><span class="p">:</span><span class="s2">"hive"</span><span class="p">,</span><span class="w">
            </span><span class="nl">"parent_author"</span><span class="p">:</span><span class="s2">"hiveio"</span><span class="p">,</span><span class="w">
            </span><span class="nl">"parent_permlink"</span><span class="p">:</span><span class="s2">"devportal-update-3-ux-improvements-more-javascript-tutorials-and-more"</span><span class="p">,</span><span class="w">
            </span><span class="nl">"title"</span><span class="p">:</span><span class="s2">""</span><span class="p">,</span><span class="w">
            </span><span class="nl">"body"</span><span class="p">:</span><span class="s2">"Excellent post very interesting friend, thanks"</span><span class="p">,</span><span class="w">
            </span><span class="nl">"json_metadata"</span><span class="p">:</span><span class="s2">"{</span><span class="se">\"</span><span class="s2">tags</span><span class="se">\"</span><span class="s2">:[</span><span class="se">\"</span><span class="s2">hive</span><span class="se">\"</span><span class="s2">],</span><span class="se">\"</span><span class="s2">app</span><span class="se">\"</span><span class="s2">:</span><span class="se">\"</span><span class="s2">hiveblog/0.1</span><span class="se">\"</span><span class="s2">}"</span><span class="p">,</span><span class="w">
            </span><span class="nl">"last_update"</span><span class="p">:</span><span class="s2">"2018-05-09T04:53:21"</span><span class="p">,</span><span class="w">
            </span><span class="nl">"created"</span><span class="p">:</span><span class="s2">"2018-05-09T04:53:21"</span><span class="p">,</span><span class="w">
            </span><span class="nl">"active"</span><span class="p">:</span><span class="s2">"2018-05-09T04:53:27"</span><span class="p">,</span><span class="w">
            </span><span class="nl">"last_payout"</span><span class="p">:</span><span class="s2">"1970-01-01T00:00:00"</span><span class="p">,</span><span class="w">
            </span><span class="nl">"depth"</span><span class="p">:</span><span class="mi">1</span><span class="p">,</span><span class="w">
            </span><span class="nl">"children"</span><span class="p">:</span><span class="mi">1</span><span class="p">,</span><span class="w">
            </span><span class="nl">"net_rshares"</span><span class="p">:</span><span class="mi">0</span><span class="p">,</span><span class="w">
            </span><span class="nl">"abs_rshares"</span><span class="p">:</span><span class="mi">0</span><span class="p">,</span><span class="w">
            </span><span class="nl">"vote_rshares"</span><span class="p">:</span><span class="mi">0</span><span class="p">,</span><span class="w">
            </span><span class="nl">"children_abs_rshares"</span><span class="p">:</span><span class="mi">0</span><span class="p">,</span><span class="w">
            </span><span class="nl">"cashout_time"</span><span class="p">:</span><span class="s2">"2018-05-16T04:53:21"</span><span class="p">,</span><span class="w">
            </span><span class="nl">"max_cashout_time"</span><span class="p">:</span><span class="s2">"1969-12-31T23:59:59"</span><span class="p">,</span><span class="w">
            </span><span class="nl">"total_vote_weight"</span><span class="p">:</span><span class="mi">0</span><span class="p">,</span><span class="w">
            </span><span class="nl">"reward_weight"</span><span class="p">:</span><span class="mi">10000</span><span class="p">,</span><span class="w">
            </span><span class="nl">"total_payout_value"</span><span class="p">:</span><span class="s2">"0.000 HBD"</span><span class="p">,</span><span class="w">
            </span><span class="nl">"curator_payout_value"</span><span class="p">:</span><span class="s2">"0.000 HBD"</span><span class="p">,</span><span class="w">
            </span><span class="nl">"author_rewards"</span><span class="p">:</span><span class="mi">0</span><span class="p">,</span><span class="w">
            </span><span class="nl">"net_votes"</span><span class="p">:</span><span class="mi">0</span><span class="p">,</span><span class="w">
            </span><span class="nl">"root_author"</span><span class="p">:</span><span class="s2">"hiveio"</span><span class="p">,</span><span class="w">
            </span><span class="nl">"root_permlink"</span><span class="p">:</span><span class="s2">"devportal-update-3-ux-improvements-more-javascript-tutorials-and-more"</span><span class="p">,</span><span class="w">
            </span><span class="nl">"max_accepted_payout"</span><span class="p">:</span><span class="s2">"1000000.000 HBD"</span><span class="p">,</span><span class="w">
            </span><span class="nl">"percent_steem_dollars"</span><span class="p">:</span><span class="mi">10000</span><span class="p">,</span><span class="w">
            </span><span class="nl">"allow_replies"</span><span class="p">:</span><span class="kc">true</span><span class="p">,</span><span class="w">
            </span><span class="nl">"allow_votes"</span><span class="p">:</span><span class="kc">true</span><span class="p">,</span><span class="w">
            </span><span class="nl">"allow_curation_rewards"</span><span class="p">:</span><span class="kc">true</span><span class="p">,</span><span class="w">
            </span><span class="nl">"beneficiaries"</span><span class="p">:[],</span><span class="w">
            </span><span class="nl">"url"</span><span class="p">:</span><span class="s2">"/hive/@hiveio/devportal-update-3-ux-improvements-more-javascript-tutorials-and-more#@andreina89/re-hiveio-devportal-update-3-ux-improvements-more-javascript-tutorials-and-more-20180509t045305223z"</span><span class="p">,</span><span class="w">
            </span><span class="nl">"root_title"</span><span class="p">:</span><span class="s2">"DevPortal Update #3: UX Improvements, More Javascript Tutorials and More!"</span><span class="p">,</span><span class="w">
            </span><span class="nl">"pending_payout_value"</span><span class="p">:</span><span class="s2">"0.000 HBD"</span><span class="p">,</span><span class="w">
            </span><span class="nl">"total_pending_payout_value"</span><span class="p">:</span><span class="s2">"0.000 HIVE"</span><span class="p">,</span><span class="w">
            </span><span class="nl">"active_votes"</span><span class="p">:[],</span><span class="w">
            </span><span class="nl">"replies"</span><span class="p">:[],</span><span class="w">
            </span><span class="nl">"author_reputation"</span><span class="p">:</span><span class="s2">"174938588721"</span><span class="p">,</span><span class="w">
            </span><span class="nl">"promoted"</span><span class="p">:</span><span class="s2">"0.000 HBD"</span><span class="p">,</span><span class="w">
            </span><span class="nl">"body_length"</span><span class="p">:</span><span class="mi">0</span><span class="p">,</span><span class="nl">"reblogged_by"</span><span class="p">:[]</span><span class="w">
        </span><span class="p">},</span><span class="w">
        </span><span class="p">{</span><span class="nl">"etc."</span><span class="p">:</span><span class="s2">"etc."</span><span class="p">}</span><span class="w">
    </span><span class="p">},</span><span class="w">
    </span><span class="nl">"accounts"</span><span class="p">:{</span><span class="w">
        </span><span class="nl">"afm007/afm007-re-hiveio-devportal-update-3-ux-improvements-more-javascript-tutorials-and-more-20180509t050215510z"</span><span class="p">:{</span><span class="w">
            </span><span class="p">{</span><span class="nl">"etc."</span><span class="p">:</span><span class="s2">"etc."</span><span class="p">}</span><span class="w">
        </span><span class="p">},</span><span class="w">
    </span><span class="p">},</span><span class="w">
    </span><span class="nl">"witnesses"</span><span class="p">:{},</span><span class="w">
    </span><span class="nl">"discussion_idx"</span><span class="p">:{},</span><span class="w">
    </span><span class="nl">"witness_schedule"</span><span class="p">:{</span><span class="w">
        </span><span class="nl">"id"</span><span class="p">:</span><span class="mi">0</span><span class="p">,</span><span class="w">
        </span><span class="nl">"current_virtual_time"</span><span class="p">:</span><span class="s2">"326078326927286190874576091"</span><span class="p">,</span><span class="w">
        </span><span class="nl">"next_shuffle_block_num"</span><span class="p">:</span><span class="mi">22307439</span><span class="p">,</span><span class="w">
        </span><span class="nl">"current_shuffled_witnesses"</span><span class="p">:[</span><span class="s2">"furion"</span><span class="p">,</span><span class="s2">"someguy123"</span><span class="p">,</span><span class="s2">"good-karma"</span><span class="p">,</span><span class="s2">"blocktrades"</span><span class="p">,</span><span class="s2">"smooth.witness"</span><span class="p">],</span><span class="w">
        </span><span class="nl">"num_scheduled_witnesses"</span><span class="p">:</span><span class="mi">21</span><span class="p">,</span><span class="w">
        </span><span class="nl">"top19_weight"</span><span class="p">:</span><span class="mi">1</span><span class="p">,</span><span class="w">
        </span><span class="nl">"timeshare_weight"</span><span class="p">:</span><span class="mi">5</span><span class="p">,</span><span class="w">
        </span><span class="nl">"miner_weight"</span><span class="p">:</span><span class="mi">1</span><span class="p">,</span><span class="w">
        </span><span class="nl">"witness_pay_normalization_factor"</span><span class="p">:</span><span class="mi">25</span><span class="p">,</span><span class="w">
        </span><span class="nl">"median_props"</span><span class="p">:{</span><span class="w">
            </span><span class="nl">"account_creation_fee"</span><span class="p">:</span><span class="s2">"0.100 HIVE"</span><span class="p">,</span><span class="w">
            </span><span class="nl">"maximum_block_size"</span><span class="p">:</span><span class="mi">65536</span><span class="p">,</span><span class="w">
            </span><span class="nl">"sbd_interest_rate"</span><span class="p">:</span><span class="mi">0</span><span class="w">
        </span><span class="p">},</span><span class="w">
        </span><span class="nl">"majority_version"</span><span class="p">:</span><span class="s2">"0.19.3"</span><span class="p">,</span><span class="w">
        </span><span class="nl">"max_voted_witnesses"</span><span class="p">:</span><span class="mi">20</span><span class="p">,</span><span class="w">
        </span><span class="nl">"max_miner_witnesses"</span><span class="p">:</span><span class="mi">0</span><span class="p">,</span><span class="w">
        </span><span class="nl">"max_runner_witnesses"</span><span class="p">:</span><span class="mi">1</span><span class="p">,</span><span class="w">
        </span><span class="nl">"hardfork_required_witnesses"</span><span class="p">:</span><span class="mi">17</span><span class="w">
    </span><span class="p">},</span><span class="w">
    </span><span class="nl">"feed_price"</span><span class="p">:{</span><span class="w">
        </span><span class="nl">"base"</span><span class="p">:</span><span class="s2">"3.484 HBD"</span><span class="p">,</span><span class="w">
        </span><span class="nl">"quote"</span><span class="p">:</span><span class="s2">"1.000 HIVE"</span><span class="w">
    </span><span class="p">},</span><span class="w">
    </span><span class="nl">"error"</span><span class="p">:</span><span class="s2">""</span><span class="w">
</span><span class="p">}</span><span class="w">
</span></code></pre></div></div>

<h4 id="3-display-replies">3. Display replies<a name="display-replies"></a></h4>

<p>Next we will format above object properly in simple user interface. From above object, we are only interested in <code class="highlighter-rouge">content</code> object which holds the data we queried.</p>

<div class="language-javascript highlighter-rouge"><div class="highlight"><pre class="highlight"><code><span class="k">if</span> <span class="p">(</span>
    <span class="o">!</span><span class="p">(</span>
        <span class="nb">Object</span><span class="p">.</span><span class="nx">keys</span><span class="p">(</span><span class="nx">result</span><span class="p">.</span><span class="nx">content</span><span class="p">).</span><span class="nx">length</span> <span class="o">===</span> <span class="mi">0</span> <span class="o">&amp;&amp;</span>
        <span class="nx">result</span><span class="p">.</span><span class="nx">content</span><span class="p">.</span><span class="kd">constructor</span> <span class="o">===</span> <span class="nb">Object</span>
    <span class="p">)</span>
<span class="p">)</span> <span class="p">{</span>
    <span class="kd">var</span> <span class="nx">replies</span> <span class="o">=</span> <span class="p">[];</span>
    <span class="nb">Object</span><span class="p">.</span><span class="nx">keys</span><span class="p">(</span><span class="nx">result</span><span class="p">.</span><span class="nx">content</span><span class="p">).</span><span class="nx">forEach</span><span class="p">(</span><span class="nx">key</span> <span class="o">=&gt;</span> <span class="p">{</span>
        <span class="kd">const</span> <span class="nx">reply</span> <span class="o">=</span> <span class="nx">result</span><span class="p">.</span><span class="nx">content</span><span class="p">[</span><span class="nx">key</span><span class="p">];</span>
        <span class="kd">const</span> <span class="nx">author</span> <span class="o">=</span> <span class="nx">reply</span><span class="p">.</span><span class="nx">author</span><span class="p">;</span>
        <span class="kd">const</span> <span class="nx">created</span> <span class="o">=</span> <span class="k">new</span> <span class="nb">Date</span><span class="p">(</span><span class="nx">reply</span><span class="p">.</span><span class="nx">created</span><span class="p">).</span><span class="nx">toDateString</span><span class="p">();</span>
        <span class="kd">const</span> <span class="nx">body</span> <span class="o">=</span> <span class="nx">md</span><span class="p">.</span><span class="nx">render</span><span class="p">(</span><span class="nx">reply</span><span class="p">.</span><span class="nx">body</span><span class="p">);</span>
        <span class="kd">const</span> <span class="nx">netvotes</span> <span class="o">=</span> <span class="nx">reply</span><span class="p">.</span><span class="nx">net_votes</span><span class="p">;</span>
        <span class="nx">replies</span><span class="p">.</span><span class="nx">push</span><span class="p">(</span>
            <span class="s2">`&lt;div class="list-group-item list-group-item-action flex-column align-items-start"&gt;\
                &lt;div class="d-flex w-100 justify-content-between"&gt;\
                  &lt;h5 class="mb-1"&gt;@</span><span class="p">${</span><span class="nx">author</span><span class="p">}</span><span class="s2">&lt;/h5&gt;\
                  &lt;small class="text-muted"&gt;</span><span class="p">${</span><span class="nx">created</span><span class="p">}</span><span class="s2">&lt;/small&gt;\
                &lt;/div&gt;\
                &lt;p class="mb-1"&gt;</span><span class="p">${</span><span class="nx">body</span><span class="p">}</span><span class="s2">&lt;/p&gt;\
                &lt;small class="text-muted"&gt;&amp;#9650; </span><span class="p">${</span><span class="nx">netvotes</span><span class="p">}</span><span class="s2">&lt;/small&gt;\
              &lt;/div&gt;`</span>
        <span class="p">);</span>
    <span class="p">});</span>
    <span class="nb">document</span><span class="p">.</span><span class="nx">getElementById</span><span class="p">(</span><span class="dl">'</span><span class="s1">replies</span><span class="dl">'</span><span class="p">).</span><span class="nx">style</span><span class="p">.</span><span class="nx">display</span> <span class="o">=</span> <span class="dl">'</span><span class="s1">block</span><span class="dl">'</span><span class="p">;</span>
    <span class="nb">document</span><span class="p">.</span><span class="nx">getElementById</span><span class="p">(</span><span class="dl">'</span><span class="s1">replies</span><span class="dl">'</span><span class="p">).</span><span class="nx">innerHTML</span> <span class="o">=</span> <span class="nx">replies</span><span class="p">.</span><span class="nx">join</span><span class="p">(</span><span class="dl">''</span><span class="p">);</span>
<span class="p">}</span>
</code></pre></div></div>

<p>We check if <code class="highlighter-rouge">content</code> is not an empty object and we iterate through each object via its key and extract, <code class="highlighter-rouge">author</code>, format <code class="highlighter-rouge">created</code> date and time, parse <code class="highlighter-rouge">body</code> markdown, get <code class="highlighter-rouge">net_votes</code> on that reply. Pushing each list item separately and displaying it. That’s it!</p>

<h3 id="to-run-the-tutorial">To Run the tutorial</h3>

<ol>
  <li><code class="highlighter-rouge">git clone https://gitlab.syncad.com/hive/devportal.git</code></li>
  <li><code class="highlighter-rouge">cd devportal/tutorials/javascript/08_get_account_replies</code></li>
  <li><code class="highlighter-rouge">npm i</code></li>
  <li><code class="highlighter-rouge">npm run dev-server</code> or <code class="highlighter-rouge">npm run start</code></li>
  <li>After a few moments, the server should be running at <a href="http://localhost:3000/">http://localhost:3000/</a></li>
</ol>

</section>

</div>
<div class="footer">
  <a href="#">Back to top</a>
</div>
<script>
    document.getElementById("open-nav").addEventListener("click", function () {
        document.body.classList.toggle("nav-open");
    });
</script>
</body>
</html>


<script src="/js/adjust.js"></script>

